<script setup>
import { ref } from 'vue'
import { Menu as IconMenu, Message, Setting, TrendCharts } from '@element-plus/icons-vue'

const isCollapse = ref(false)
</script>

<template>
  <div class="app-container">
    <el-menu
      class="sidebar"
      :collapse="isCollapse"
      :router="true"
      :default-active="$route.path"
      background-color="#F4F6F9"
      text-color="#111111"
      active-text-color="#409EFF">
      <div class="collapse-btn" @click="isCollapse = !isCollapse">
        <el-icon><IconMenu /></el-icon>
      </div>
      <el-menu-item index="/">
        <el-icon><Message /></el-icon>
        <template #title>问答</template>
      </el-menu-item>
    </el-menu>
    <div class="main-content">
      <div class="content-wrapper">
        <router-view />
      </div>
    </div>
  </div>
</template>

<style>
.app-container {
  display: flex;
  height: 100vh;
  background-color: #F4F6F9;
  border: none; /* 确保容器无边框 */
}

.sidebar {
  height: 100%;
  width: 200px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: none !important; /* 消除右侧边框 */
}

.sidebar.el-menu--collapse {
  width: 64px;
  border-right: none !important;
}

/* 覆盖Element Plus默认样式 */
:deep(.el-menu) {
  border-right: none !important;
}

/* 覆盖菜单项的边框样式 */
:deep(.el-menu-item) {
  border-right: none !important;
}

.main-content {
  flex: 1;
  overflow: hidden;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  flex: 1;
  background-color: #ffffff;
  margin: 20px;
  border-radius: 8px;
  overflow: auto;
  padding: 20px;
  color: #fff;
}

.collapse-btn {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #868A94;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapse-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

:deep(.el-menu-item) {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:deep(.el-menu-item .el-icon) {
  transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:deep(.el-menu-item span) {
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
</style>